How VHS Replication Works
When replication is enabled, any new value (whether the value is the result of an edit, addition, or delete) is written to the change queue (VhsChangeQueue.dat) of the VHS source service. Each item in the queue is given a unique sequence number by the source service. The replicated service keeps track of the sequence number of the last record it received. If the sequence numbers match it indicates that the replicated service is up to date with the source service. If the sequence numbers of the most recent records are different, it indicates that there have been new changes to the source service. This triggers the replicated service to retrieve the new value from the source service and commit it to its own database.
If a replicated service is shut down, it writes the last sequence number it has processed to the file ReplicationPersist.dat in the service data folder. This allows it to resume replication from the point it left off when the service starts back up. If the change queue rolls over or the ReplicationPersist.dat file is deleted while the replicated service is stopped, upon startup it will begin replicating at the beginning of the change queue. If this occurs, it is possible that the replicated VHS will miss changes that have occurred in the source service.
Unlike other CygNet services, a replicated VHS does not ever perform a full resynchronization against the source VHS. The size of a typical VHS database and the sheer number of values does not make this a feasible option. Replicated VHS(s) can only begin committing incremental changes if the source VHS is writing its changes to its incremental change queue. For this reason the source and replicating VHS(s) may not have identical contents. The source VHS may have older data in it that was never put on the change queue, or a replicated service may have its own older data from before it started replicating data.
A source service and its replicated service can get out of sync if the source service’s change queue is too small; the replicated service is not running while the source service is running; or if the source service loses its change queue. With other types of services, if the source and replicated service get out of sync, a complete resynchronization is performed. This is not possible with the VHS due to the sheer number of records. If a source VHS and its replicated service get out of sync, the only option to determine the missing date range and attempt to recover values in that range. See Replication Missed Change Events for information about determining the missing data date/time range.
Sample Implementation
Replicated services can be run in parallel from the same source or they can be chained together as illustrated below.
|
Sample Replication |

